<html>
<head><meta charset="utf-8"><title>UB in the nomicon · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html">UB in the nomicon</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="171323136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/171323136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#171323136">(Jul 20 2019 at 11:07)</a>:</h4>
<p>I am updating what the nomicon calls UB: <a href="https://github.com/rust-lang-nursery/nomicon/pull/149" target="_blank" title="https://github.com/rust-lang-nursery/nomicon/pull/149">https://github.com/rust-lang-nursery/nomicon/pull/149</a><br>
Is there anything else that should be added to that list?</p>



<a name="171323588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/171323588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#171323588">(Jul 20 2019 at 11:21)</a>:</h4>
<p>I'd also appreciate some extra eyes on <a href="https://github.com/rust-lang/rust/pull/62822" target="_blank" title="https://github.com/rust-lang/rust/pull/62822">https://github.com/rust-lang/rust/pull/62822</a></p>



<a name="171329748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/171329748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#171329748">(Jul 20 2019 at 14:34)</a>:</h4>
<p>"function pointers are pointers that point to <em>code</em>, not data"</p>
<blockquote>
<p>[Lisp programmers screaming in the distance]</p>
</blockquote>



<a name="171329765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/171329765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#171329765">(Jul 20 2019 at 14:35)</a>:</h4>
<p>Nomicon i left a comment, the main rust docs look good with no changes</p>



<a name="174059401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174059401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nick12 <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174059401">(Aug 24 2019 at 23:53)</a>:</h4>
<p>Should the reference also be updated?<br>
<a href="https://doc.rust-lang.org/reference/behavior-considered-undefined.html" target="_blank" title="https://doc.rust-lang.org/reference/behavior-considered-undefined.html">https://doc.rust-lang.org/reference/behavior-considered-undefined.html</a></p>



<a name="174059440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174059440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nick12 <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174059440">(Aug 24 2019 at 23:54)</a>:</h4>
<p>I'm particularly thinking of <code>Reads of undef (uninitialized) memory.</code></p>



<a name="174059442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174059442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nick12 <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174059442">(Aug 24 2019 at 23:54)</a>:</h4>
<p>Regardless of if that is technically correct or not, it gives a very different picture than what the nomicon currently says I think</p>



<a name="174075408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174075408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174075408">(Aug 25 2019 at 08:36)</a>:</h4>
<blockquote>
<p>Should the reference also be updated?<br>
<a href="https://doc.rust-lang.org/reference/behavior-considered-undefined.html" target="_blank" title="https://doc.rust-lang.org/reference/behavior-considered-undefined.html">https://doc.rust-lang.org/reference/behavior-considered-undefined.html</a></p>
</blockquote>
<p>yeah I have updating that on my list</p>



<a name="174079528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174079528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174079528">(Aug 25 2019 at 10:53)</a>:</h4>
<p>here's the Reference UB PR: <a href="https://github.com/rust-lang-nursery/reference/pull/659" target="_blank" title="https://github.com/rust-lang-nursery/reference/pull/659">https://github.com/rust-lang-nursery/reference/pull/659</a></p>



<a name="174080988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174080988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174080988">(Aug 25 2019 at 11:40)</a>:</h4>
<p>If we wanted to say that "Unwinding from Rust into other languages is UB", we'd have to police other languages to never define the behavior of calling a Rust function that unwinds.</p>



<a name="174080995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174080995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174080995">(Aug 25 2019 at 11:41)</a>:</h4>
<p>I don't see how we could achieve that, in particular, given that anybody can write an ASM snippet that calls a Rust function, and handles its unwinding correctly.</p>



<a name="174081003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174081003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174081003">(Aug 25 2019 at 11:41)</a>:</h4>
<p>They'd tell you that in assembly the behavior of doing that is perfectly defined, and they would be right <span aria-label="laughter tears" class="emoji emoji-1f602" role="img" title="laughter tears">:laughter_tears:</span></p>



<a name="174081507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174081507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174081507">(Aug 25 2019 at 11:58)</a>:</h4>
<blockquote>
<p>If we wanted to say that "Unwinding from Rust into other languages is UB", we'd have to police other languages to never define the behavior of calling a Rust function that unwinds.</p>
</blockquote>
<p>no. it's never wrong to call too many things UB. it might just be a bad idea.</p>



<a name="174081516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174081516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174081516">(Aug 25 2019 at 11:59)</a>:</h4>
<p>OTOH, given all the discussion around unwinding into extern fn, I think it is crucial that that is reflected in this list somehow. if you have suggestions for improving the wording, please share them. :)</p>



<a name="174083670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174083670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174083670">(Aug 25 2019 at 13:09)</a>:</h4>
<p>The problem with this is that such UB is unverifiable</p>



<a name="174083718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174083718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174083718">(Aug 25 2019 at 13:10)</a>:</h4>
<p>And adding it serves no purpose, because its not up to us to say what's UB and what isn't in other programming languages</p>



<a name="174083799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174083799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174083799">(Aug 25 2019 at 13:13)</a>:</h4>
<p>The moment we unwind from a function, we are not in that function anymore</p>



<a name="174083849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174083849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174083849">(Aug 25 2019 at 13:14)</a>:</h4>
<p>So if we unwind from Rust code into another programming language, we are in that other programming language</p>



<a name="174083857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174083857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174083857">(Aug 25 2019 at 13:15)</a>:</h4>
<p>If you want to say that unwinding from Rust into that language is UB, you should do so in the spec of that language</p>



<a name="174083861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174083861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174083861">(Aug 25 2019 at 13:15)</a>:</h4>
<p>The Rust spec does not hold there</p>



<a name="174089935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174089935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174089935">(Aug 25 2019 at 16:09)</a>:</h4>
<blockquote>
<p>And adding it serves no purpose, because its not up to us to say what's UB and what isn't in other programming languages</p>
</blockquote>
<p>this is on the interface between us and other languages, so it is as much our territory as theirs. both languages have to work together to make this behave properly, but either language can just say "nope, not supported".</p>



<a name="174090001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174090001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174090001">(Aug 25 2019 at 16:10)</a>:</h4>
<blockquote>
<p>The problem with this is that such UB is unverifiable</p>
</blockquote>
<p>just like UB caused by mismatching FFI with C. we'd need a cross-language abstract machine or so to make this precise and verifiable.</p>



<a name="174090751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174090751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174090751">(Aug 25 2019 at 16:29)</a>:</h4>
<p>to me this feels like writing a german law that says that once you cross the border to austria, you can't have potatoes in the car</p>



<a name="174090880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174090880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174090880">(Aug 25 2019 at 16:32)</a>:</h4>
<p>with the twist that germany wouldn't know where the border to austria is and wouldn't have any way to check it</p>



<a name="174090903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174090903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174090903">(Aug 25 2019 at 16:33)</a>:</h4>
<p>and that crossing border with potatos in the car is otherwise fine, and that having potatoes in the car in austria is also potentially fine</p>



<a name="174090929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174090929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174090929">(Aug 25 2019 at 16:33)</a>:</h4>
<p>and then not do it only with austria, but with all other countries, and well with the obvious consequence that if you happen to actually cross to another country with potatoes in the care, german law doesn't hold there, so you can just eat your potatoes, and come back</p>



<a name="174091000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091000">(Aug 25 2019 at 16:35)</a>:</h4>
<p>this creates the problem that it is not sufficient for other languages, of which there are many, that they support Rust functions unwinding, but that we would also need to mention that for every such language</p>



<a name="174091158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091158">(Aug 25 2019 at 16:38)</a>:</h4>
<p>If we do want to support cross-language unwinding, then listing languages we intend to be compatible with is neither sensible nor necessary. We can just describe our unwinding ABI and others can implement it.</p>



<a name="174091178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091178">(Aug 25 2019 at 16:39)</a>:</h4>
<p>Our unwinding ABI is unspecified</p>



<a name="174091185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091185">(Aug 25 2019 at 16:39)</a>:</h4>
<p>This means that any language can read our source code, and implement it, and still be compatible with some particular rust toolchain version</p>



<a name="174091247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091247">(Aug 25 2019 at 16:40)</a>:</h4>
<p>So even without explicit intent to support cross-language unwinding, it would be "fine" to do so.</p>



<a name="174091272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091272">(Aug 25 2019 at 16:41)</a>:</h4>
<p>Stating on our end that we consider unwinding out of Rust to be UB is stressing that we really don't want people to do that and won't even try to keep that working. Someone hacking something unsupported together against a specific implementation of a spec is always possible and never makes it "not UB".</p>



<a name="174091320"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091320" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091320">(Aug 25 2019 at 16:42)</a>:</h4>
<p>Sure, but we also say that Rust's unwinding ABI is unspecified, and not undefined</p>



<a name="174091329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091329">(Aug 25 2019 at 16:43)</a>:</h4>
<p>I don't understand why we shouldn't use the scariest language available that is correct.</p>



<a name="174091335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091335">(Aug 25 2019 at 16:43)</a>:</h4>
<p>And it <strong>is</strong> correct to say that the Rust language considers it UB.</p>



<a name="174091382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091382">(Aug 25 2019 at 16:44)</a>:</h4>
<p>We can, but it sends a mixed message given that we have been supporting this UB in stable for a year now, while having it panic on nightly in some cases.</p>



<a name="174091405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091405">(Aug 25 2019 at 16:45)</a>:</h4>
<blockquote>
<p>and then not do it only with austria, but with all other countries, and well with the obvious consequence that if you happen to actually cross to another country with potatoes in the care, german law doesn't hold there, so you can just eat your potatoes, and come back</p>
</blockquote>
<p>to stretch that stretched analogy further: you cannot come back as German police will prosecute you for breaking German law. The border itself, where the crime happened, is still something that Germany has jurisdiction on.</p>



<a name="174091452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091452">(Aug 25 2019 at 16:46)</a>:</h4>
<p>Sure, but germany has no way to tell. Unless it is a goal to, e.g., create a cross-lang abstract machine between Rust, and e.g., assembly</p>



<a name="174091461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091461">(Aug 25 2019 at 16:47)</a>:</h4>
<blockquote>
<p>We can, but it sends a mixed message given that we have been supporting this UB in stable for a year now, while having it panic on nightly in some cases.</p>
</blockquote>
<p>that's why I am asking for wording that excludes that case.<br>
cross-langauge FFI is like a puzzle, <em>both</em> sides have to make it fit. so this is where we specify the rules on our side.</p>



<a name="174091466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091466">(Aug 25 2019 at 16:47)</a>:</h4>
<p>You also argue that the crime happened at the border, but I think that the crime happens in the other country</p>



<a name="174091467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091467">(Aug 25 2019 at 16:47)</a>:</h4>
<p>this is true both of exceptions <em>entering</em> and <em>leaving</em> any language's domain</p>



<a name="174091473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091473">(Aug 25 2019 at 16:47)</a>:</h4>
<p>if you weren't in another country you couldn't have commited the crime in the first place</p>



<a name="174091516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091516">(Aug 25 2019 at 16:48)</a>:</h4>
<p>so we could say something like "unwinding out of an <code>#[unwind(allowed)] extern fn</code> into a language with incompatible unwinding ABI", or so</p>



<a name="174091521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091521">(Aug 25 2019 at 16:48)</a>:</h4>
<p>we can't use <code>#[unwind(allowed)]</code> in the reference because its unstable :/</p>



<a name="174091525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091525">(Aug 25 2019 at 16:49)</a>:</h4>
<p>we can add a note saying that this is unstable, and that on stable this is the default attribute</p>



<a name="174091526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091526">(Aug 25 2019 at 16:49)</a>:</h4>
<p>in stable Rust the only thing that controls what can unwind is the "ABI" string</p>



<a name="174091532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091532">(Aug 25 2019 at 16:49)</a>:</h4>
<p>or we can just leave away the attribute</p>



<a name="174091533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091533">(Aug 25 2019 at 16:49)</a>:</h4>
<p>The lang team position for stable Rust is that it's UB to unwind across any FFI at all, and no amount of hairsplitting will change that</p>



<a name="174091537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091537">(Aug 25 2019 at 16:49)</a>:</h4>
<p>I dont think we have to mention the ABI string... if some other langauge calls a <code>extern "Rust" fn</code>, the rules are still the same</p>



<a name="174091586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091586">(Aug 25 2019 at 16:50)</a>:</h4>
<p>and by some other language, we need to consider also Rust-with-different-toolchain</p>



<a name="174091596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091596">(Aug 25 2019 at 16:50)</a>:</h4>
<p>sure. I dont think this is the right place to define all FFI terminology, we can leave that open until someone bothers to add an appropriate chapter.</p>



<a name="174091602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091602">(Aug 25 2019 at 16:51)</a>:</h4>
<p><span class="user-mention" data-user-id="124289">@rkruppe</span> stable Rust does not enforce that for Rust-Rust FFI</p>



<a name="174091605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091605">(Aug 25 2019 at 16:51)</a>:</h4>
<p>or does it ?</p>



<a name="174091608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091608">(Aug 25 2019 at 16:51)</a>:</h4>
<p>Since when does UB have to be enforced?</p>



<a name="174091651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091651">(Aug 25 2019 at 16:52)</a>:</h4>
<p>Look I know how messy the situation is in reality, but de jure it's all UB and UB is UB.</p>



<a name="174091653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091653">(Aug 25 2019 at 16:52)</a>:</h4>
<blockquote>
<p>The lang team position for stable Rust is that it's UB to unwind across any FFI at all, and no amount of hairsplitting will change that</p>
</blockquote>
<p>well the lang team is also not fundamentally opposed to an <code>unwind(allowed)</code> attribute, and has agreed to beta-backports for PR that avoid abort-on-unwind-through-FFI</p>



<a name="174091655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091655">(Aug 25 2019 at 16:52)</a>:</h4>
<p>So.. in stable Rust the standard library can do Rust-Rust FFI, because it makes use of a special language feature ?</p>



<a name="174091661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091661">(Aug 25 2019 at 16:53)</a>:</h4>
<blockquote>
<p>So.. in stable Rust the standard library can do Rust-Rust FFI, because it makes use of a special language feature ?</p>
</blockquote>
<p>You make it sound like that's in any way special. libstd always does lots of magic stuff.</p>



<a name="174091665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091665">(Aug 25 2019 at 16:53)</a>:</h4>
<p>I know, but Rust-Rust FFI is used so much, I don't know if it is only used within libstd</p>



<a name="174091667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091667">(Aug 25 2019 at 16:53)</a>:</h4>
<p>so "unwinding into another language is UB" does not reflect Rust-as-it-is-used and the lang team has agreed to <em>not</em> killing crates that want to unwind out of Rust.</p>



<a name="174091668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091668">(Aug 25 2019 at 16:53)</a>:</h4>
<p>or through lang items</p>



<a name="174091712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091712">(Aug 25 2019 at 16:54)</a>:</h4>
<blockquote>
<blockquote>
<p>The lang team position for stable Rust is that it's UB to unwind across any FFI at all, and no amount of hairsplitting will change that</p>
</blockquote>
<p>well the lang team is also not fundamentally opposed to an <code>unwind(allowed)</code> attribute, and has agreed to beta-backports for PR that avoid abort-on-unwind-through-FFI</p>
</blockquote>
<p>The context there was what goes into the reference which mostly (though still non-normatively) defines the rules of stable Rust. That we've not shipped certain changes which are possible under those rules isn't relevant for what the rules are.</p>



<a name="174091716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091716">(Aug 25 2019 at 16:54)</a>:</h4>
<p>but IMO a reasonable approach would also be to say "unwinding across lang barrier is UB" in this PR, and then open an issue to make this more precise (less UB) to adjust for reality.</p>



<a name="174091725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091725">(Aug 25 2019 at 16:55)</a>:</h4>
<p>I think it has become clear that this PR is the wrong place to try to resolve this</p>



<a name="174091728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091728">(Aug 25 2019 at 16:55)</a>:</h4>
<p>I'd say, just c&amp;p what the nomicon now says, or what the reference was saying before, and open an issue</p>



<a name="174091775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091775">(Aug 25 2019 at 16:56)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> that issue is <a href="https://github.com/rust-lang/rust/issues/58794" target="_blank" title="https://github.com/rust-lang/rust/issues/58794">https://github.com/rust-lang/rust/issues/58794</a></p>



<a name="174091790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091790">(Aug 25 2019 at 16:57)</a>:</h4>
<p>that issue somehow mixes FFI with <code>extern "C"</code></p>



<a name="174091796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091796">(Aug 25 2019 at 16:58)</a>:</h4>
<p>As in, a lot there, and the RFC, uses FFI to refer exclusively to <code>extern "C"</code>.</p>



<a name="174091837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091837">(Aug 25 2019 at 16:58)</a>:</h4>
<p>hm that issue is more for the abort-on-panic-shim actually</p>



<a name="174091841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091841">(Aug 25 2019 at 16:58)</a>:</h4>
<p>this would be the place for your concern I think: <a href="https://github.com/rust-lang/rfcs/pull/2699" target="_blank" title="https://github.com/rust-lang/rfcs/pull/2699">https://github.com/rust-lang/rfcs/pull/2699</a></p>



<a name="174091854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091854">(Aug 25 2019 at 16:59)</a>:</h4>
<p>I already raised it there, took a bit of convincing and PRs to update the reference</p>



<a name="174091871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091871">(Aug 25 2019 at 16:59)</a>:</h4>
<p>There is also the misconception that <code>fn()</code> is different from <code>extern "Rust" fn()</code></p>



<a name="174091942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091942">(Aug 25 2019 at 17:00)</a>:</h4>
<p>yeah, the <code>extern</code> keyword here is confusing</p>



<a name="174091956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174091956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174091956">(Aug 25 2019 at 17:01)</a>:</h4>
<p>yes, very</p>



<a name="174092724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174092724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nick12 <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174092724">(Aug 25 2019 at 17:25)</a>:</h4>
<p>Is extern "Rust" abi fully defined/documented? I dont think it makes much sense to talk about ffi with it being stable otherwise. Should a possible third party Rust compiler or other languages trying to do ffi with the Rust abi be considered?</p>



<a name="174097030"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174097030" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174097030">(Aug 25 2019 at 19:32)</a>:</h4>
<p>no it is not documented</p>



<a name="174097039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174097039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174097039">(Aug 25 2019 at 19:33)</a>:</h4>
<p>so by definition it is incompatible with anything</p>



<a name="174131468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174131468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174131468">(Aug 26 2019 at 10:55)</a>:</h4>
<p>AFAIK the Rust ABI (layout, calling convention, ...) is except for some very basic guarantees,  technically _unspecified_. That is, it is something that we say it exists, but we do not require any Rust implementation to document what it is, or to implement it in any specific way (beyond some basic guarantees).</p>



<a name="174131532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174131532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174131532">(Aug 26 2019 at 10:56)</a>:</h4>
<blockquote>
<p>Should a possible third party Rust compiler or other languages trying to do ffi with the Rust abi be considered?</p>
</blockquote>
<p>That's possible, brittle, but possible.</p>



<a name="174131552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174131552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174131552">(Aug 26 2019 at 10:57)</a>:</h4>
<p>You can use two different Rust toolchains to compile two different Rust static libraries where functions use the Rust ABI, link them, have them call each other, and ifffff both compilers implement the Rust ABI in the same way, then that's actually guaranteed to work (why wouldn't it?).</p>



<a name="174131611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174131611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174131611">(Aug 26 2019 at 10:58)</a>:</h4>
<p>That's two different compilers, implementing the Rust ABI, and code compiling with those interfacing</p>



<a name="174131624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174131624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174131624">(Aug 26 2019 at 10:58)</a>:</h4>
<p>The same applies to GDB, LLDB, and other debugging tools that need to understand the Rust ABI to be useful</p>



<a name="174131949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB%20in%20the%20nomicon/near/174131949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/UB.20in.20the.20nomicon.html#174131949">(Aug 26 2019 at 11:05)</a>:</h4>
<p>Because the ABI is unspecified, and most of it can change any time, all of this can break any time</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>